# encoding: utf-8
# Author    : limusen
# Datetime  : 2023/10/19 11:07
# File      : register_pages.py
# explain   : 文件说明


from common.browse import Browser
from common.base import Base
from page_objects.locator import register_locator as rl


class RegisterPages(Base):

    def open(self):
        self.open_url(rl.register_url)

    def register_user(self, kwargs):
        self.open()

        self.send_keys(rl.username, kwargs['username'])
        self.send_keys(rl.password, kwargs['password'])
        self.send_keys(rl.re_password, kwargs['re_password'])
        self.get_page_img(rl.get_captcha, 'code')
        codes = self.ImageRecognition()
        print(codes)
        self.send_keys(rl.captcha, codes)
        self.wait(1)
        self.click(rl.register_button)


if __name__ == '__main__':
    from common.browse import Browser

    driver = Browser().get_driver()
    rg = RegisterPages(driver)
    info = {
        'username': 'nishishenmeniuma',
        'password': 111111,
        're_password': 111111,
    }
    rg.register_user(info)
